Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kernelCTF CVE-2024-53141_lts #150

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

st424204
Copy link
Contributor

@st424204 st424204 commented Jan 7, 2025

No description provided.

@st424204 st424204 force-pushed the CVE-2024-53141_lts branch 2 times, most recently from 9e224ca to 80e6eee Compare January 7, 2025 07:55
@st424204 st424204 force-pushed the CVE-2024-53141_lts branch from 80e6eee to 87044ae Compare January 7, 2025 08:01
@koczkatamas koczkatamas force-pushed the master branch 3 times, most recently from 933028d to c111d81 Compare March 3, 2025 14:31
@koczkatamas koczkatamas force-pushed the master branch 5 times, most recently from fe221aa to aa7067b Compare March 13, 2025 14:34
@koczkatamas koczkatamas force-pushed the master branch 8 times, most recently from 76d6b57 to bf0d68f Compare March 13, 2025 15:39
Copy link
Collaborator

@koczkatamas koczkatamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

This is just a quick code quality review. We're planning to review the submissions more deeply (actually understanding what the exploit does) in two weeks.

In general, the code quality looks acceptable, but we may have further comments during the deeper review. I've also left a few comments now.

We also have a draft style guide now. Please take a look and let us know if it's helpful for understanding our code quality expectations: https://google.github.io/security-research/kernelctf/style_guide.

Thanks for the submission and PR!

}

// Function to create an IP set under kmalloc-cg-1024 cache
int create_ip_set_kmalloc_1024(int sock_fd, const char *set_name, const char *type_name, uint8_t family, int extra)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a significant code reuse (copy-paste) in the following functions: create_ip_set_kmalloc_1024, trigger_oob_leak, create_ip_set_kmalloc_2048, add_ip_to_set and trigger_oob_write.

If you would create a helper function for the generic part and keep only the code which differs in these functions, the reader could more easily understand the differences.

See more details here: https://google.github.io/security-research/kernelctf/style_guide#code-duplication

{
// if reach target loop, we spray a lot kmalloc-cg-2048 msg_msgseg ahead
for (int i = 0; i < 0x1000; i++)
SYSCHK(msgsnd(msqid[i], &msg, 0x1000 - 0x30 + 0x800 - 0x8, 0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using PAGE_SIZE - MSG_MSG_SIZE + KMALLOC_CG_2K - MSG_MSGSEG_SIZE instead of 0x1000 - 0x30 + 0x800 - 0x8 can make it easier for readers to understand where these values come from, but in this case the comment about kmalloc-cg-2048 helps a lot as well.

More detail here: https://google.github.io/security-research/kernelctf/style_guide#approach-2

}

// make comment_string be allocated under kmalloc-192
memset(comment_string, 'a', 0x90);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be also moved into the trigger_oob_leak function directly or here directly before the trigger_oob_leak call as it's only used there (and comment_string can be a local variable instead of a global one). This way it would be easier to follow what's going on.

SYSCHK(setrlimit(RLIMIT_NOFILE, &rlim));


// prepare a lot unix_socket for spray skbs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify how much allocation happens here? 0x400000 is 4MB, we allocate that 0x400 times for 2 FDs recv and sndbuf, that's 4M * 1024 * 4 = 16Gb of memory? That seems to be more than the VM has...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants